//
//  CustomBaseSubViewController.m
//  AmountBody
//
//  Created by Qiu Jishuai on 2018/1/6.
//  Copyright © 2018年 RCMTM. All rights reserved.
//

#import "CustomBaseSubViewController.h"
#import <Masonry/Masonry.h>
#import "CustomContainerView.h"
#import "CustomConstants.h"

@interface CustomBaseSubViewController ()
@end

@implementation CustomBaseSubViewController

- (CustomContainerView *)rightContainerView {
    if (!_rightContainerView) {
        _rightContainerView = [[CustomContainerView alloc] init];
        [_rightView addSubview:_rightContainerView];
        [_rightContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(_rightView);
        }];
    }
    return _rightContainerView;
}

- (CustomNextButton *)nextButton {
    if (!_nextButton) {
        _nextButton = [[CustomNextButton alloc] init];
        [_nextButton addTarget:self action:@selector(jumpToNext) forControlEvents:UIControlEventTouchUpInside];
    }
    return _nextButton;
}

- (void)jumpToNext {

}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.leftView = [[UIView alloc] init];
    [self.view addSubview:_leftView];

    self.rightView = [[UIView alloc] init];
    [self.view addSubview:_rightView];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    [_leftView mas_remakeConstraints:^(MASConstraintMaker *make) {
        layoutViews(^{ //横屏
            make.top.left.bottom.equalTo(self.view);
            make.width.equalTo(@(kCustomLandscapeLeftWidth));
        }, ^{ //竖屏
            make.top.left.right.equalTo(self.view);
            make.height.equalTo(@(kCustomPortraitTopHeight));
        });
    }];

    [_rightView mas_remakeConstraints:^(MASConstraintMaker *make) {
        layoutViews(^{ //横屏
            make.left.equalTo(_leftView.mas_right);
            make.top.right.bottom.equalTo(self.view);
        }, ^{ //竖屏
            make.left.right.bottom.equalTo(self.view);
            make.top.equalTo(_leftView.mas_bottom);
        });
    }];

    layoutViews(^{ //横屏
        if (_nextButton) {
            _nextButton.hidden = NO;
            [self.view addSubview:_nextButton];
            [self.view bringSubviewToFront:_nextButton];
            [_nextButton mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.centerX.equalTo(self.view);
                make.width.height.equalTo(@40);
                make.bottom.equalTo(self.view);
            }];
        }
    }, ^{ //竖屏
        if (_nextButton) {
            _nextButton.hidden = YES;
        }
    });
}

@end
